﻿using System;
using System.Windows.Input;
using MediaBrowser.CustomControls.MouseCursors;

namespace MediaBrowser.Gui.MvvmUtils.UI
{
    /// <summary>
    /// using (new CustomWaitCursor())
    /// {
    ///    .. Do work here ..
    /// }
    /// </summary>
    public class CustomWaitCursor : IDisposable
    {
        private readonly Cursor _oldCursor;

        /// <summary>
        /// Constructor
        /// </summary>
        public CustomWaitCursor()
        {
            _oldCursor = Mouse.OverrideCursor;
            Mouse.OverrideCursor = CustomMouseCursors.Wait;
        }

        /// <summary>
        /// Returns the cursor to the default state.
        /// </summary>
        public void Dispose()
        {
            Mouse.OverrideCursor = _oldCursor;
        }
    }
}
